﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lib
{ 
    public class SessionBox
    {
        /// <summary>
        /// 登记User Session
        /// </summary>
        /// <param name="userinfo"></param>
        public static void CreateUserSession(UserSession userinfo)
        {
            System.Web.HttpContext.Current.Session["USER"] = userinfo;
        }

        /// <summary>
        /// 获取User Session
        /// </summary>
        /// <returns></returns>
        public static UserSession GetUserSession()
        {
            object o = System.Web.HttpContext.Current.Session["USER"];
            if (o == null) throw new ExceptionSession("读取UserSession失败。");
            else return (o as UserSession);
        }

    }
}